package com.woniuxy.main.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.UpdateProvider;

import com.woniuxy.main.pojo.Student;


import com.woniuxy.main.pojo.User;
import com.woniuxy.main.pojo.Vi_user_student;
import com.woniuxy.main.provider.StudentProvider;



public interface StudentMapper {

	// 根据uid查询学员sid
	@Select("select sid from student where uid=#{uid}")
	public int findSidByUid(int uid);

	// 更新学生信息
	@UpdateProvider(type=StudentProvider.class,method="studentUpdate")
	public int addUserStuInfo(Student student);

	//根据sid获取用户uid和money
	@Select("select user.uid,money,payPwd from `order` inner join student on order.sid=student.sid inner join user on student.uid=user.uid where order.oid=#{oid} ")
	public User getUser(int oid);
	
	//根据学员id查学员个人信息
	@Select("select * from student where sid=#{sid}")
	public Student findStudentBySid(int sid);
	
	@Select("select COUNT(*) from `order` where sid=#{sid} and status=2")
	public int findOrderCount(int sid);
	
	@Select("select COUNT(*) from comment where sid=#{sid} and commentRank>=4")
	public int findPositiveCount(int sid);
	//创建学生表
	@Insert("insert into student(uid) values(#{uid})")
	public int insertStudent(int uid);
	
	//查询所有用户-学员信息
	@Select("select * from vi_user_student")
	public List<Vi_user_student> findAllStudent();
}



